/** 邮件发送记录 */
import request from '@/utils/request'

/** 电子邮件 */

/** 新增电子邮件
 * @params {object} data 邮件数据
 */
export function postEmailRecord(data, params) {
  // if (typeof params === 'object') {
  //   params = JSON.stringify(params)
  // }
  return request({
    method: 'POST',
    url: `/call-center/api/v1/emailRecord/insert`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

/** 修改电子邮件
 * @params {object} data 邮件数据
 */
export function putEmailRecord(data) {
  return request({
    method: 'PUT',
    url: '/call-center/api/v1/emailRecord',
    data
  })
}

/** 查询所有电子邮件
 */
export function getEmailRecord() {
  return request({
    method: 'GET',
    url: '/call-center/api/v1/emailRecord/'
  })
}
/** 根据id查询电子邮件
 * @params {number} id 邮件id
 */
export function getByIdEmailRecord(id) {
  return request({
    method: 'GET',
    url: `/call-center/api/v1/emailRecord/${id}`
  })
}
/** 删除电子邮件
 * @params {number} id 邮件id
 */
export function deleteByIdEmailRecord(id) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v1/emailRecord/${id}`
  })
}
/** 批量删除电子邮件
 * @params {array[string]} ids
 */
export function deleteBatch(ids) {
  return request({
    method: 'DELETE',
    url: '/call-center/api/v1/emailRecord/deleteBatch',
    data: {
      ids
    }
  })
}
/** 分页获取电子邮件
 * @params {object} data 分页参数
*/
export function pageEmail(data) {
  return request({
    method: 'POST',
    url: '/call-center/api/v1/emailRecord/page',
    data
  })
}
/** 分页获取电子邮件主题
 * @params {object} data 分页参数
*/
export function pageEmailTheme(data) {
  return request({
    method: 'POST',
    url: '/call-center/api/v1/emailRecord/subject',
    data
  })
}
